package com.tsunami.base.service.impl;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tsunami.base.service.IBaseService;
import com.tsunami.utils.StringUtils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * 服务实现基类
 *
 * @author lx
 * @date 2024-11-01
 */
public class BaseServiceImpl<M extends BaseMapper<T>,T> extends ServiceImpl<M,T> implements IBaseService<T> {

    @Override
    public Boolean remove(String ids) {
        if(StringUtils.isEmpty(ids)){
            return false;
        }
        String[] idss = ids.split(",");
        List<Long> idList = Arrays.stream(idss)
                .map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
        for (Long id:idList) {
            super.removeById(id);
        }
        return true;
    }
}
